import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

export default defineConfig({
	plugins: [
		vue(),
		createSvgIconsPlugin({
			iconDirs: [resolve(process.cwd(), 'src/assets/svgIcon')],
			symbolId: 'ui-svg_[name]',
			inject: 'body-first'
		}),
	],
	base: '',
	resolve: {
		alias: {
			'@': '/src' // 别名
		},
		extensions: ['.js', '.json', '.vue', '.scss', '.css', '.svg']
	},
	css: {
		preprocessorOptions: {
			scss: {
				
			}
		}
	},
	json: {
		namedExports: true,
		stringify: true
	},
	server: {
		host: '0.0.0.0',
		open: true,
		port: 8888,
		cors: true,
		proxy: {
			'^/api|/pubsrc': {
				target: 'http://localhost:8712/',
				// rewrite: path => path.replace(/^\/api/, ''),
				changeOrigin: true
			}
		}
	},
	build: {
		target: 'es2015',
		outDir: 'dist',
		reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
		chunkSizeWarningLimit: 1024, // chunk 大小警告的限制（单位kb）
	}
})